package com.yqg.protection.mapper;

import com.yqg.protection.entity.Agreement;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zxf
 * @since 2024-09-11
 */
@Mapper
public interface AgreementMapper extends BaseMapper<Agreement> {

    @Select("select * from (select agreement.*, user.username as operatorName from agreement left join user on agreement.operator_id = user.id) as t where t.agreement_name like '%${name}%' and t.is_delete = 0 order by t.id limit #{pageNum},#{pageSize}")
    List<Agreement> findPage(Integer pageNum, Integer pageSize, String name);

    @Select("select count(*) from agreement where agreement_name like '%${name}%' and is_delete = 0")
    Long findPageCount(String name);

    @Select("select * from (select agreement.*, user.username as operatorName from agreement left join user on agreement.operator_id = user.id) as t where t.agreement_name like '%${name}%' and t.is_delete = 0 order by t.id")
    List<Agreement> exportData(String name);
}
